//类
//类名称建议开头字母大写
class Component{
    public width:number //成员属性
    public height:number //成员属性
    constructor(width:number,height:number){//构造函数，用于在内存中创建类的实例对象
        console.log('实例化对象')
        this.width = width
        this.height = height
    }
}
//创建实例对象 按钮组件
let btnComponent:Component = new Component(100,20)
let imageComponent:Component = new Component(200,200)
// console.log(btnComponent)  
// console.log(imageComponent)  

//继承
//Input 输入框组件，自有属性value （width，height，value）
class Input extends Component{
   private value:string //设置自有属性
   constructor(width:number,height:number,value:string){
      super(width,height)  //super()方法，调用父类的构造函数，继承父类的属性
      console.log('实例化对象')
      this.value = value
   }
}
let inputComponent:Input = new Input(100,40,'admin')
console.log(inputComponent)
//练习继承语法，定义Btn类型，继承自Component，同时有自有属性backgroundColor
//            定义Image类型，继承自Component，同时有自有属性src




//练习:创建学生类型Student,成员属性有：sid sname sage
class Student{
    sid:number
    sname:string
    sage:number
    constructor(sid:number,sname:string,sage:number){
        this.sid = sid
        this.sname = sname
        this.sage = sage
    }
}
let stu1:Student = new Student(101,'tom',18)
// console.log(stu1)
let stu2:Student = new Student(102,'jim',20)
// console.log(stu2)

